from PyQt6.QtWidgets import QWidget, QLabel, QVBoxLayout
from PyQt6.QtCore import Qt


class PatternPreviewWidget(QWidget):
    """图案预览组件"""

    def __init__(self, parent=None):
        super().__init__(parent)
        self.init_ui()

    def init_ui(self):
        """初始化用户界面"""
        layout = QVBoxLayout(self)
        self.preview_label = QLabel("图案预览区")
        self.preview_label.setAlignment(Qt.AlignmentFlag.AlignCenter)
        self.preview_label.setStyleSheet("""
            background-color: white;
            border: 1px solid #ccc;
            border-radius: 5px;
            padding: 20px;
        """)
        layout.addWidget(self.preview_label)

    def set_pattern(self, pattern: str, modes: list):
        """设置图案"""
        if pattern and modes:
            self.preview_label.setText(f"当前图案: {pattern}\n拼摆方式: {', '.join(modes)}")
        else:
            self.preview_label.setText("选择图案和拼摆方式预览效果")